<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单应收款" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doShow(id){
		var url="/business/BusinessBillEdit.ihtm?id="+id+"&alert_type=NONE";
		ShowIframe("业务单",url,1024,600,"refreshWin()",1024,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location="/business/BusinessBillListForReceive.ihtm?"+getSearchCondition()+"&current_page=${qr.pageIndex}";
		}
	}
	function doReceive(id,tsId){
		var dfTsId="${currentUser.user.dfTsId}";
		if(tsId!=null && dfTsId!=tsId){//tsId==null是从doMutiReceive()过来的
			ShowAlert('提示框','业务单的帐套与当前开单帐套不一致，不能操作',200,100);
			return;
		}
		var url="/finance/ReceiveBillNew.ihtm?data_type=BUSINESS&business_bill_id_str="+id;
		ShowIframe("收款",url,1024,500,"doReceiveCallBack()",1024,600);
	}
	function doReceiveCallBack(){
		if(popRetVal!=null){
			var url="/business/BusinessBillListForReceive.ihtm?"+getSearchCondition()+"&current_page=${qr.pageIndex}";
			if(popRetVal.indexOf(";")!=-1){
				var arr=popRetVal.split(";");
				if(arr[1]!=null && arr[1]=="Y"){
					url=url+"&print_id="+arr[0]+"&print_bill=REC";
					if(arr[2]!=null){
						url=url+"&print_detail="+arr[2];
					}
				}
			}
			window.location=url;
		}
	}
	function doMutiReceive(){
		var arr=getMultiSelectValue();
		if(arr[0]!=""){
			ShowAlert('提示框',arr[0],200,100);
		}else{
			if(arr[1]!=""){
				doReceive(arr[1]);
			}else{
				ShowAlert('提示框','请选择要收款的业务单',200,100);
			}
		}
	}
	function doAdjust(id,tsId){
		var dfTsId="${currentUser.user.dfTsId}";
		if(tsId!=null && dfTsId!=tsId){
			ShowAlert('提示框','业务单的帐套与当前开单帐套不一致，不能操作',200,100);
			return;
		}
		var url="/finance/AdjustTypeSelect.ihtm?bill_type=BUSINESS_BILL";
		ShowIframeNoScroll("选择调帐类型",url,240,230,"doAdjustExt('"+id+"')");
	}
	function doAdjustExt(id){
		if(popRetVal!=null){
			var url="/finance/AdjustBillNew.ihtm?data_type=BILL&adjust_type="+popRetVal+"&bill_id_str="+id;
			ShowIframe("调帐",url,1024,500,"doAdjCallBack()",1024,600);
		}
	}
	function doAdjCallBack(){
		if(popRetVal!=null){
			var url="/business/BusinessBillListForReceive.ihtm?"+getSearchCondition()+"&current_page=${qr.pageIndex}";
			if(popRetVal.indexOf(";")!=-1){
				var arr=popRetVal.split(";");
				if(arr[1]!=null && arr[1]=="Y"){
					url=url+"&print_id="+arr[0]+"&print_bill=ADJ";
				}
			}
			window.location=url;
		}
	}
	function doMutiAdjust(){
		var arr=getMultiSelectValue();
		if(arr[0]!=""){
			ShowAlert('提示框',arr[0],200,100);
		}else{
			if(arr[1]!=""){
				doAdjust(arr[1]);
			}else{
				ShowAlert('提示框','请选择要调账的业务单',200,100);
			}
		}
	}
	function getMultiSelectValue(){
		var r=new Array();
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		var clientId="";
		var dfTsId="${currentUser.user.dfTsId}";
		
		for (i=0;i<ob_arr.length;i++){
			if (ob_arr[i].checked == true){
				if(clientId==""){
					clientId=ob_arr[i].getAttribute("clientId");
				}else{
					if(clientId!=ob_arr[i].getAttribute("clientId")){
						r[0]="不同客户的业务单不能一起操作";
						r[1]="";
						return r;
					}
				}
				if(dfTsId!=ob_arr[i].getAttribute("tsId")){
					r[0]="业务单"+ob_arr[i].getAttribute("billCode")+"的帐套与当前开单帐套不一致，不能操作";
					r[1]="";
					return r;
				}
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		
		r[0]="";
		r[1]=str;
		return r;
	}
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function createPageParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("end_date").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("est_name").value);
		str=str+"&cont_code="+encodeURIComponent(document.getElementById("cont_code").value);
		str=str+"&pm="+document.getElementById("pm").value;
		str=str+"&area="+document.getElementById("area").value;
		str=str+"&est_type="+document.getElementById("est_type").value;
		str=str+"&est_level="+document.getElementById("est_level").value;
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("bill_code").value);
		str=str+"&content="+encodeURIComponent(document.getElementById("content").value);
		str=str+"&linkman="+encodeURIComponent(document.getElementById("linkman").value);
		str=str+"&mng_name="+encodeURIComponent(document.getElementById("mng_name").value);
		str=str+"&foll_name="+encodeURIComponent(document.getElementById("foll_name").value);
		
		var timeouted="A";
		if(document.getElementById("timeout1").checked){
			timeouted="Y";
		}else if(document.getElementById("timeout2").checked){
			timeouted="N";
		}
		str=str+"&timeouted="+timeouted;
		
		var status="A";
		if(document.getElementById("status1").checked){
			status="DELIVERED";
		}else if(document.getElementById("status2").checked){
			status="COMPLETED";
		}
		str=str+"&status="+status;
		
		str=str+"&min_cost="+encodeURIComponent(document.getElementById("min_cost").value.trim());
		str=str+"&max_cost="+encodeURIComponent(document.getElementById("max_cost").value.trim());
		str=str+"&ts_id="+document.getElementById("ts_id").value;
		
		return str;
	}
	function createProgramParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("hid_start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("hid_end_date").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("hid_est_name").value);
		str=str+"&cont_code="+encodeURIComponent(document.getElementById("hid_cont_code").value);
		str=str+"&pm=${pm}";
		str=str+"&area=${area}";
		str=str+"&est_type=${estType}";
		str=str+"&est_level=${estLevel}";
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("hid_bill_code").value);
		str=str+"&content="+encodeURIComponent(document.getElementById("hid_content").value);
		str=str+"&linkman="+encodeURIComponent(document.getElementById("hid_linkman").value);
		str=str+"&mng_name="+encodeURIComponent(document.getElementById("hid_mng_name").value);
		str=str+"&foll_name="+encodeURIComponent(document.getElementById("hid_foll_name").value);
		str=str+"&timeouted=${timeouted}";
		str=str+"&status=${status}";
		str=str+"&min_cost="+encodeURIComponent(document.getElementById("hid_min_cost").value);
		str=str+"&max_cost="+encodeURIComponent(document.getElementById("hid_max_cost").value);
		str=str+"&ts_id=${tsId}";
		
		return str;
	}
	function doSearch(){
		var str;
		if(IsAdvSearch){//高级
			str="search_type=1";
			if(document.getElementById("cb_order_date").checked){
				if(checkDateStr()){
					str=str+"&cb_order_date=1";
				}else{
					return;
				}
			}
			if(document.getElementById("cb_status").checked){
				str=str+"&cb_status=1";
			}
			if(document.getElementById("cb_est").checked){
				var estName=document.getElementById("est_name").value.trim();
				if(estName==null || estName==""){
					ShowAlert('提示框','请输入订货单位',200,100);
					return;
				}
				str=str+"&cb_est=1";
			}
			
			if(document.getElementById("cb_cont_code").checked){
				var contCode=document.getElementById("cont_code").value.trim();
				if(contCode==null || contCode==""){
					ShowAlert('提示框','请输入合同号',200,100);
					return;
				}
				str=str+"&cb_cont_code=1";
			}
			if(document.getElementById("cb_pm").checked){
				var pm=document.getElementById("pm").value;
				if(pm==null || pm=="" || pm=="0"){
					ShowAlert('提示框','请选择付款方式',200,100);
					return;
				}
				str=str+"&cb_pm=1";
			}
			if(document.getElementById("cb_area").checked){
				var area=document.getElementById("area").value;
				if(area==null || area=="" || area=="0"){
					ShowAlert('提示框','请选择地区',200,100);
					return;
				}
				str=str+"&cb_area=1";
			}
			if(document.getElementById("cb_est_type").checked){
				var estType=document.getElementById("est_type").value;
				if(estType==null || estType=="" || estType=="0"){
					ShowAlert('提示框','请选择客户类别',200,100);
					return;
				}
				str=str+"&cb_est_type=1";
			}
			if(document.getElementById("cb_est_level").checked){
				var estLevel=document.getElementById("est_level").value;
				if(estLevel==null || estLevel=="" || estLevel=="0"){
					ShowAlert('提示框','请选择客户等级',200,100);
					return;
				}
				str=str+"&cb_est_level=1";
			}
			if(document.getElementById("cb_bill_code").checked){
				var billCode=document.getElementById("bill_code").value.trim();
				if(billCode==null || billCode==""){
					ShowAlert('提示框','请输入业务单号',200,100);
					return;
				}
				str=str+"&cb_bill_code=1";
			}
			if(document.getElementById("cb_content").checked){
				var content=document.getElementById("content").value.trim();
				if(content==null || content==""){
					ShowAlert('提示框','请输入摘要',200,100);
					return;
				}
				str=str+"&cb_content=1";
			}
			if(document.getElementById("cb_linkman").checked){
			   var linkman=document.getElementById("linkman").value.trim();
			   if(linkman==null || linkman==""){
			      ShowAlert('提示框','请输入联系人',200,100);
			      return;
			   }
			   str=str+"&cb_linkman=1";
			}
			if(document.getElementById("cb_mng").checked){
				var mngName=document.getElementById("mng_name").value.trim();
				if(mngName==null || mngName==""){
					ShowAlert('提示框','请输入业务员姓名',200,100);
					return;
				}
				str=str+"&cb_mng=1";
			}
			if(document.getElementById("cb_foll").checked){
				var follName=document.getElementById("foll_name").value.trim();
				if(follName==null || follName==""){
					ShowAlert('提示框','请输入跟单人姓名',200,100);
					return;
				}
				str=str+"&cb_foll=1";
			}
			if(document.getElementById("cb_timeout").checked){
				str=str+"&cb_timeout=1";
			}
			if(document.getElementById("cb_cost").checked){
				var minCost=document.getElementById("min_cost").value.trim();
				if(minCost==null || minCost==""){
					ShowAlert('提示框','请输入最小金额',200,100);
					return;
				}else if(isNaN(minCost)){
					ShowAlert('提示框','最小金额只能是数字',200,100);
					return;
				}
				var maxCost=document.getElementById("max_cost").value.trim();
				if(maxCost==null || maxCost==""){
					ShowAlert('提示框','请输入最大金额',200,100);
					return;
				}else if(isNaN(maxCost)){
					ShowAlert('提示框','最大金额只能是数字',200,100);
					return;
				}
				str=str+"&cb_cost=1";
			}
			if(document.getElementById("cb_ts").checked){
				var tsId=document.getElementById("ts_id").value;
				if(tsId==null || tsId=="" || tsId=="0"){
					ShowAlert('提示框','请选择帐套',200,100);
					return;
				}
				str=str+"&cb_ts=1";
			}
		}else{//快速
			str="search_type=2";
		}
		var paraStr=createPageParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		window.location="/business/BusinessBillListForReceive.ihtm?"+str;
	}
	function doGo(pageIndex){
		var str=getSearchCondition();
		str=str+"&current_page="+pageIndex;
		window.location="/business/BusinessBillListForReceive.ihtm?"+str;
	}
	function getSearchCondition(){
		var searchType="${searchType}";
		var str="search_type="+searchType;
		if(searchType=="1"){//高级
			<c:if test="${cbOrderDate=='1'}">str=str+"&cb_order_date=1";</c:if>
			<c:if test="${cbEst=='1'}">str=str+"&cb_est=1";</c:if>
			<c:if test="${cbContCode=='1'}">str=str+"&cb_cont_code=1";</c:if>
			<c:if test="${cbPm=='1'}">str=str+"&cb_pm=1";</c:if>
			<c:if test="${cbArea=='1'}">str=str+"&cb_area=1";</c:if>
			<c:if test="${cbEstType=='1'}">str=str+"&cb_est_type=1";</c:if>
			<c:if test="${cbEstLevel=='1'}">str=str+"&cb_est_level=1";</c:if>
			<c:if test="${cbCost=='1'}">str=str+"&cb_cost=1";</c:if>
			<c:if test="${cbTs=='1'}">str=str+"&cb_ts=1";</c:if>
			<c:if test="${cbBillCode=='1'}">str=str+"&cb_bill_code=1";</c:if>
			<c:if test="${cbContent=='1'}">str=str+"&cb_content=1";</c:if>
			<c:if test="${cbLinkman=='1'}">str=str+"&cb_linkman=1";</c:if>
			<c:if test="${cbMng=='1'}">str=str+"&cb_mng=1";</c:if>
			<c:if test="${cbFoll=='1'}">str=str+"&cb_foll=1";</c:if>
			<c:if test="${cbTimeout=='1'}">str=str+"&cb_timeout=1";</c:if>
			<c:if test="${cbStatus=='1'}">str=str+"&cb_status=1";</c:if>
		}else{//快速
			
		}
		var paraStr=createProgramParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		return str;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var id="";
		if(ob_arr.length>=it.getAttribute("index")){
			id=ob_arr[it.getAttribute("index")-1].value;
		}
		if(id==""){
			return;
		}
		doShow(id);
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/business/BusinessBillListForReceive.ihtm?content_type=EXCEL&"+str;
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		//Window_Onload();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doAutoCheck(objId){
		document.getElementById(objId).checked=true;
	}
	function doPrintCallBack(){
		var printId="${printId}";
		var printBill="${printBill}";
		var printDetail="${printDetail}";
		if(printId!=null && printId!=""){
			if(printBill=="REC"){
				showWin(900,600,"/finance/ReceiveBillPrint.ihtm?id="+printId+"&print_detail="+printDetail);
			}else if(printBill=="ADJ"){
				showWin(900,600,"/finance/AdjustBillPrint.ihtm?id="+printId);
			}
		}
	}
	function selectStafferName(objId,checkObjId){
		var url="/base/StafferMainForSelect.ihtm";
		var cb="selectStafferNameCallBack('"+objId+"','"+checkObjId+"')";
		ShowIframe("选择员工",url,800,500,cb);
	}
	function selectStafferNameCallBack(objId,checkObjId){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			document.getElementById(objId).value=arr[1];
			doAutoCheck(checkObjId);
		}
	}
	function selectEstName(){
		var url="/base/EstablishmentListForSelect.ihtm?type=CLIENT";
		ShowIframe("选择客户",url,900,500,"selectEstNameCallBack()");
	}
	function selectEstNameCallBack(){
		if(popRetVal!=null){
			document.getElementById("est_name").value=popRetVal[1];
			doAutoCheck("cb_est");
		}
	}
</script>
</head>
<body oncontextmenu="return false">
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1>业务单应收款</h1>
	            <span class="Note">查询到所有未收完款的业务单，进行收款与调账操作</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fl">
	            	<table class="MoreOption" cellpadding="0" cellspacing="0">
	            		<th class="c1" width="90px">
	            			<input type="checkbox" name="cb_status" id="cb_status" <c:if test="${cbStatus=='1' || searchType=='2'}">checked="true"</c:if> style="visibility:hidden;" />
	            			业务单状态
	            		</th>
	            		<td class="c1" width="260px">
	            			<input type="radio" name="status" id="status1" onClick="doAutoCheck('cb_status');" <c:if test="${status=='DELIVERED'}">checked="true"</c:if> >已送货
							<input type="radio" name="status" id="status2" onClick="doAutoCheck('cb_status');" <c:if test="${status=='COMPLETED'}">checked="true"</c:if> >已完工
							<input type="radio" name="status" id="status3" onClick="doAutoCheck('cb_status');" <c:if test="${status==null || status=='' || status=='A'}">checked="true"</c:if> >全部
	            		</td>
	            	</table>
	            </span>
	            <span class="fr">
	            	<a href="javascript:;" id="lnkMoreOption">更多查询选项</a>
		  			<input type="button" value=" 查 询" onClick="doSearch();" class="buttom search-but" id="sSearchButton" name="sSearchButton">
	                <c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';RECE_BILL;')!=-1}">
						<input type="button" class="buttom  search-rec" id="sReceiveButton" name="sReceiveButton"  value=" 收 款" onClick="doMutiReceive();">
					</c:if>
					<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';ADJU_BILL;')!=-1}">
						<input type="button" class="buttom  search-adjust" id="sAdjustButton" name="sAdjustButton" value=" 调 账" onClick="doMutiAdjust();">
					</c:if>
					<input type="button" class="buttom search-out" id="sDownloadButton" name="sDownloadButton" value=" 导 出" onClick="doDownload();" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
	            </span>
				<div id="dvMoreOptionBox" class="MoreOptionBox" style="display:none;">
					<table class="MoreOption" cellpadding="0" cellspacing="0">
						<tr>
							<th class="c1" width="90px">
			        			<input type="checkbox" name="cb_est" id="cb_est" <c:if test="${cbEst=='1'}">checked="true"</c:if>>
			        			订货单位
			        		</th>
			        		<td class="c1" width="260px">
			        			<input type="text" class="TextBox" maxlength="50" name="est_name" id="est_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_est');" value="<c:out value="${estName}" />" >
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectEstName();" />
								<input type="hidden" id="hid_est_name" value="<c:out value="${estName}" />">
			    			</td>
			    			<th class="c2" width="80px">
	                        	<input name="" type="checkbox" name="cb_order_date" id="cb_order_date" <c:if test="${cbOrderDate=='1'}">checked="true"</c:if> />
	                        	订货日期
	                        </th>
	                        <td width="250px">
	                        	<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_order_date');" id="start_date" name="start_date" value="<c:out value="${startDate}" />" >
								<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_order_date\')');">
								<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
					            	至
								<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_order_date');" id="end_date" name="end_date" value="<c:out value="${endDate}" />" >
								<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_order_date\')');">
								<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
	                    	</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_linkman" id="cb_linkman" <c:if test="${cbLinkman=='1'}">checked="true"</c:if>>
			        			联系人
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="linkman" id="linkman" onFocus="doAutoCheck('cb_linkman');" onKeyUp="checkInput();" value="<c:out value="${linkman}" />">
								<input type="hidden" id="hid_linkman" value="<c:out value="${linkman}" />">
							</td>
	                    	<th class="c2">
	                        	<input type="checkbox" name="cb_timeout" id="cb_timeout" <c:if test="${cbTimeout=='1'}">checked="true"</c:if>>
	                        	是否超期
	                        </th>
	                    	<td class="c2">
	                        	<input type="radio" name="timeouted" id="timeout1" onClick="doAutoCheck('cb_timeout');" <c:if test="${timeouted=='Y'}">checked="true"</c:if> >已超期
								<input type="radio" name="timeouted" id="timeout2" onClick="doAutoCheck('cb_timeout');" <c:if test="${timeouted=='N'}">checked="true"</c:if> >未超期
								<input type="radio" name="timeouted" id="timeout3" onClick="doAutoCheck('cb_timeout');" <c:if test="${timeouted==null || timeouted=='' || timeouted=='A'}">checked="true"</c:if> >全部
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cont_code" id="cb_cont_code" <c:if test="${cbContCode=='1'}">checked="true"</c:if>>
			        			合同号
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="cont_code" id="cont_code" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cont_code');" value="<c:out value="${contCode}" />" >
								<input type="hidden" id="hid_cont_code" value="<c:out value="${contCode}" />">
							</td>
							<th class="c2">
	                        	<input type="checkbox" name="cb_pm" id="cb_pm" <c:if test="${cbPm=='1'}">checked="true"</c:if>>
	                        	付款方式
	                        </th>
	                    	<td class="c3">
	                        	<select name="pm" id="pm" onFocus="doAutoCheck('cb_pm');">
					  				<option value="0">==请选择==</option>
					  				<c:forEach var="item" items="${pmList}">
					  				<c:if test="${item.enabled=='Y'}"><option value="${item.id}" <c:if test="${pm==item.id}">selected</c:if>>${item.modeName}</option></c:if>
					  				</c:forEach>
				  				</select>
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_bill_code" id="cb_bill_code" <c:if test="${cbBillCode=='1'}">checked="true"</c:if>>
			        			业务单号
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="bill_code" id="bill_code" onFocus="doAutoCheck('cb_bill_code');" onKeyUp="checkInput();" value="<c:out value="${billCode}" />">
								<input type="hidden" id="hid_bill_code" value="<c:out value="${billCode}" />">
			    			</td>
			    			<th class="c2">
	                        	<input type="checkbox" name="cb_area" id="cb_area" <c:if test="${cbArea=='1'}">checked="true"</c:if>>
	                        	地区
	                        </th>
	                    	<td class="c3">
	                    		<select name="area" id="area" onFocus="doAutoCheck('cb_area');">
									<option value="0">==请选择==</option>
									<commonTag:createSelectTree list="${areaList}" emptyOption="0" justEnabled="1" defaultValue="${area}" />
								</select>
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_content" id="cb_content" <c:if test="${cbContent=='1'}">checked="true"</c:if>>
			        			摘要
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="content" id="content" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_content');" value="${content}" >
								<input type="hidden" id="hid_content" value="<c:out value="${content}" />">
			    			</td>
			    			<th class="c2">
	                        	<input type="checkbox" name="cb_est_type" id="cb_est_type" <c:if test="${cbEstType=='1'}">checked="true"</c:if>>
	                        	客户类别
	                        </th>
	                    	<td class="c3">
	                        	<select name="est_type" id="est_type" onFocus="doAutoCheck('cb_est_type');">
					  				<option value="0">==请选择==</option>
					  				<c:forEach var="item" items="${estTypeList}">
					  				<option value="${item.id}" <c:if test="${estType==item.id}">selected</c:if>>${item.typeName}</option>
					  				</c:forEach>
				  				</select>
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cost" id="cb_cost" <c:if test="${cbCost=='1'}">checked="true"</c:if>>
			        			欠款金额
			        		</th>
			    			<td>
			        			<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cost');" id="min_cost" name="min_cost" value="${minCost}">
								至
								<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cost');" id="max_cost" name="max_cost" value="${maxCost}">
								<input type="hidden" id="hid_min_cost" value="<c:out value="${minCost}" />">
								<input type="hidden" id="hid_max_cost" value="<c:out value="${maxCost}" />">
			    			</td>
			    			<th class="c2">
	                        	<input type="checkbox" name="cb_est_level" id="cb_est_level" <c:if test="${cbEstLevel=='1'}">checked="true"</c:if>>
	                        	客户等级
	                        </th>
	                    	<td class="c3">
	                        	<select name="est_level" id="est_level" onFocus="doAutoCheck('cb_est_level');">
					  				<option value="0">==请选择==</option>
					  				<c:forEach var="item" items="${estLevelList}">
					  				<option value="${item.id}" <c:if test="${estLevel==item.id}">selected</c:if>>${item.levelName}</option>
					  				</c:forEach>
				  				</select>
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_ts" id="cb_ts" <c:if test="${cbTs=='1'}">checked="true"</c:if>>
	                        	账套
			        		</th>
			    			<td class="c1">
			        			<select name="ts_id" id="ts_id" onFocus="doAutoCheck('cb_ts');">
				    				<option value="0">==请选择账套==</option>
				    				<c:forEach var="item" items="${tsList}">
									<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option></c:forEach>
								</select>
			        		</td>
			        		<th class="c2">
			        			<input type="checkbox" name="cb_mng" id="cb_mng" <c:if test="${cbMng=='1'}">checked="true"</c:if>>
			        			业务员
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox" maxlength="15" name="mng_name" id="mng_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_mng');" value="<c:out value="${mngName}" />" >
	                        	<img src="/images/make-a.gif" class="imgIconButton" onClick="selectStafferName('mng_name','cb_mng');" />
	                        	<input type="hidden" id="hid_mng_name" value="<c:out value="${mngName}" />">
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">&nbsp;</th>
			    			<td class="c1">&nbsp;</td>
			        		<th class="c2">
			        			<input type="checkbox" name="cb_foll" id="cb_foll" <c:if test="${cbFoll=='1'}">checked="true"</c:if>>
			        			跟单员
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox" maxlength="15" name="foll_name" id="foll_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_foll');" value="<c:out value="${follName}" />" >
	                        	<img src="/images/make-a.gif" class="imgIconButton" onClick="selectStafferName('foll_name','cb_foll');" />
	                        	<input type="hidden" id="hid_foll_name" value="<c:out value="${follName}" />">
			    			</td>
			    		</tr>
			    	</table>
			    
			    	<div class="OptionOrderBy">
	                    <span class="fr"><a href="javascript:;" id="lnkHiddenOption">隐藏查询选项</a></span>
	                </div>
				</div>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>
	        
	        <c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_TOTA;')==-1}">
			<div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>
	                		<span>欠款合计：${remainTotal}元</span>&nbsp;&nbsp;
							<span>业务单数：${qr.totalCount}笔</span>
	                	</td>
	            	</tr>
	            </table>
			</div>
			</c:if>

		    <div class="table-list">
		        <table width="100%">
		          	<tr>  
						<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
						<th width="11%">业务单号</th>
						<th width="8%">订货日期</th>
						<th width="10%">订货单位</th>
						<th width="8%">摘要</th>
						<th width="8%">结账日期</th>
						<th width="6%">付款方式</th>
						<th width="7%">总额</th>
						<th width="7%">已收</th>
						<th width="6%">调账</th>
						<th width="7%">欠款</th>
						<th width="6%">业务员</th>
						<th width="6%">跟单员</th>
						<th width="10%">操作</th>
		          	</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item[0].id}" clientId="${item[0].clientId}" tsId="${item[0].tallySetId}" billCode="${item[0].billCode}"></td>
						<td>${item[0].billCode}</td>
						<td><fmt:formatDate value="${item[0].orderDate}" pattern="yyyy-MM-dd"/></td>
						<td>${item[1]}<c:if test="${item[0].linkman!=null && item[0].linkman!=''}">(${item[0].linkman})</c:if></td>
						<td><c:out value="${item[0].content}" /></td>
						<td>
							<c:if test="${item[0].checkDate!=null}">
							<fmt:formatDate value="${item[0].checkDate}" pattern="yyyy-MM-dd"/>
							</c:if>
						</td>
						<td><commonTag:showSimpleObjectName list="${pmList}" objectId="${item[0].payModeId}" /></td>
						<td align="right">${item[0].cost}</td>
						<td align="right">${item[2]}</td>
						<td align="right">${item[3]}</td>
						<td align="right">${item[0].cost-item[2]+item[3]}</td>
						<td>${item[0].managerName}</td>
						<td>${item[0].followerNameStr}</td>
						<td>
							<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';RECE_BILL;')!=-1}">
								<a href="#" onClick="doReceive('${item[0].id}','${item[0].tallySetId}');">收款</a>
							</c:if>
							<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';ADJU_BILL;')!=-1}">
								<a href="#" onClick="doAdjust('${item[0].id}','${item[0].tallySetId}');">调账</a>
							</c:if>
							<a href="javascript:doShow('${item[0].id}');">查看</a>
						</td>
					</tr>
					</c:forEach>              
				</table>
			
			</div>
			
			<!-- 底栏 分页、操作等 -->
	        <div class="BottomToolBar ClearFix">
			    <%@include file="../inc/Pages.jsp"%>
	        </div>
			
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<970 ) w1 = 960;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
		doPrintCallBack();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	
	    var lnkMoreOption   = document.getElementById('lnkMoreOption');
	    var lnkHiddenOption = document.getElementById('lnkHiddenOption');
	    lnkMoreOption.onclick = function(){
	    	IsAdvSearch = true;
	        document.getElementById('dvMoreOptionBox').style.display = 'block';
	        document.getElementById('cb_status').style.visibility = 'visible';
	        this.style.visibility = 'hidden';
	    };
	    lnkHiddenOption.onclick = function(){
	    	IsAdvSearch = false;
	        document.getElementById('dvMoreOptionBox').style.display = 'none';
	        document.getElementById('cb_status').style.visibility = 'hidden';
	        lnkMoreOption.style.visibility = 'visible';
	    };
	})();
</script>
